home *** CD-ROM | disk | FTP | other *** search
/ PC Home 138 / PC Home issue 138.iso / Software / Essentials / Netscape / nim.xpi / bin / chrome / aim.jar / content / aim / migration.js < prev    next >
Encoding:
JavaScript  |  2002-10-13  |  14.5 KB  |  586 lines

  1. //Global Variables
  2. var gSelectedRadioItem;    // Remembers the chosen screenname if the user hits the back button.
  3. var gCurPage;              // Remembers the current page you are on, so finish knows what setup panel to get the screenname from.
  4. var whichPath = "";        // Keeps track of which of the three choices the user has  made at the beginning of the wizard
  5.  
  6. //*************************//
  7. //      Panel One JS       //
  8. //*************************//
  9.  
  10.  
  11. /*
  12.  * Function: page1onLoad
  13.  *
  14.  * Arguments: None
  15.  * 
  16.  * Return: None
  17.  *
  18.  * Description: Calls the function to setup what radio button options the
  19.  *              user will see in the wizard when it loads.
  20.  */
  21.  
  22. function page1onLoad()
  23. {
  24.   setInitialPanel();
  25.   gCurPage = 1;
  26. }
  27.  
  28.  
  29. function page1Advanced(){
  30.  if(whichPath == "downstreamActivation"){
  31.     if (gAcctTypeOnPageHandlerKicked){
  32.        return true;
  33.     }
  34.      setEntryPoint("downstreamActivation");
  35.      setNewAccountGlobals();
  36.      pingForTransactionUrls();
  37.      return false;
  38.      }
  39.      else{
  40.        if(whichPath == "setUseMyScreenName")
  41.        {
  42.          if (gAcctTypeOnPageHandlerKicked){
  43.            return true;
  44.          }
  45.          setEntryPoint("downstreamActivation");
  46.          setExistingAccountGlobals();
  47.          pingForTransactionUrls();
  48.          return false;
  49.        }
  50.        return true;
  51.      
  52.      }
  53. }
  54.  
  55.  
  56. /*
  57.  * Function: setInitialPanel()
  58.  *
  59.  * Arguments: None
  60.  * 
  61.  * Return: None
  62.  *
  63.  * Description: Determines if the user activated or not.  If so, gives them the option to use the ID they activated for aim.  If not,
  64.  * hides that functionality from them.
  65.  *
  66. */
  67.  
  68. function setInitialPanel()
  69. {
  70.   var firstScreen = aimPrefsManager().GetCharPref("aim.session.screenname", null, true);
  71.   //we need to make  sure we set the correct radio button depending on whether the  
  72.   //user is coming back to this panel, or if it is the first time.
  73.   //document.getElementById("wizchoices").selectedItem = null;
  74.   
  75.   switch(whichPath)
  76.   {
  77.      case "useActivatedName":
  78.       document.getElementById('netcenter').setAttribute('selected','true');
  79.       //document.getElementById('migration').setAttribute('selected','false');
  80.       //document.getElementById('setupname').setAttribute('selected','false');
  81.       setUseActivatedName();
  82.       break;
  83.    
  84.      case "setUseMyScreenName":
  85.       //document.getElementById('netcenter').setAttribute('selected','false');
  86.       document.getElementById('migration').setAttribute('selected','true');
  87.       //document.getElementById('setupname').setAttribute('selected','false');
  88.       setUseMyScreenName();
  89.       break;
  90.    
  91.      case "downstreamActivation":
  92.       //document.getElementById('netcenter').setAttribute('selected','false');
  93.       //document.getElementById('migration').setAttribute('selected','false');
  94.       document.getElementById('setupname').setAttribute('selected','true');
  95.       setUseNewScreenName();
  96.       break;
  97.       
  98.      default:
  99.      //determine starting wizard panel
  100.      if (firstScreen && firstScreen != '')
  101.      {
  102.       var aimBundle   = document.getElementById('bundle_aim');  // Lets us access the AIM String Bundle.
  103.       var text1       = aimBundle.getString("migwiz.text1");
  104.       var text2       = aimBundle.getString("migwiz.text2");
  105.       
  106.       document.getElementById('netcenter').setAttribute("label", text1 + firstScreen + text2);
  107.       document.getElementById('netcenter').setAttribute('selected','true');
  108.       //document.getElementById('migration').setAttribute('selected','false');
  109.       //document.getElementById('setupname').setAttribute('selected','false');
  110.       
  111.    
  112.       setUseActivatedName();
  113.      }
  114.      else
  115.      {
  116.       //document.getElementById('netcenter').setAttribute('selected','false');
  117.       document.getElementById('netcenter').setAttribute('hidden','true');
  118.       document.getElementById('migration').setAttribute('selected','true');
  119.       //document.getElementById('setupname').setAttribute('selected','false');
  120.       
  121.       setUseMyScreenName();
  122.      }
  123.      break;
  124.    }
  125.  
  126.   //determine ending wizard panel
  127.   gEndPageId = "pdone";
  128.  
  129. }
  130.  
  131.  
  132. /*
  133.  * Function: setUseActivatedName
  134.  *
  135.  * Arguments: none
  136.  * 
  137.  * Return: none
  138.  *
  139.  * Description: Sets the next page to be the Netcenter activation explaination page.
  140.  */
  141.  
  142. function setUseActivatedName()
  143. {
  144.   document.getElementById('p1').next='p2';
  145.   whichPath = "useActivatedName";
  146. }
  147.  
  148.  
  149. /*
  150.  * Function: setUseMyScreenName
  151.  *
  152.  * Arguments: none
  153.  * 
  154.  * Return: none
  155.  *
  156.  * Description: Sets the next page depending on a. platform, and b. if the 'MigrateDiscover()' 
  157.  *              function finds any existing screennames on your computer.
  158.  */
  159.  
  160. function setUseMyScreenName()
  161. {
  162.   whichPath = "setUseMyScreenName";
  163.  // if (navigator.platform != 'MacPPC')
  164.  // {
  165.  //   var ret = MigrateDiscover();
  166.  //   if ( MigrateDiscover() == false )
  167.  //     document.getElementById('p1').next='p3';
  168.  //   else
  169.  //     document.getElementById('p1').next='p4';
  170.  // }
  171.  // else
  172.     // we need to go through the activation screens
  173.     // to detemine if the screen name has NetscapeNetwork
  174.     // flag set
  175.     document.getElementById('p1').next='ispPage3';
  176.     setNextPage("ispPage3", "ispPage5");
  177.     setNextPage("ispPage5","pdone");
  178. }
  179.  
  180.  
  181. /*
  182.  * Function: setUseNewScreenName
  183.  *
  184.  * Arguments: none
  185.  * 
  186.  * Return: none
  187.  *
  188.  * Description: Sets the next page to be the New Screen Name explaination page.
  189.  */
  190.  
  191. function setUseNewScreenName()
  192. {
  193.   whichPath = "downstreamActivation";
  194.   document.getElementById('p1').next='ispPage4';
  195.   setNextPage("ispPage4","ispPage5");
  196.   setNextPage("ispPage5","ispPage6");
  197.   setNextPage("ispPage6","pdone");
  198.  
  199.   
  200.  
  201. }
  202.  
  203.  
  204.  
  205. //*************************//
  206. //      Panel Two JS       //
  207. //*************************//
  208.  
  209.  
  210. /*
  211.  * Function: page2onLoad
  212.  *
  213.  * Arguments: None
  214.  * 
  215.  * Return: None
  216.  *
  217.  * Description: Fires when the 3rd page is loaded.  Sets focus on the relevant widget.
  218.  */
  219.  
  220. function page2onLoad()
  221. {
  222.   gCurPage = 2;
  223. }
  224.  
  225.  
  226.  
  227. //*************************//
  228. //     Panel Three JS      //
  229. //*************************//
  230.  
  231.  
  232. /*
  233.  * Function: page3onLoad
  234.  *
  235.  * Arguments: None
  236.  * 
  237.  * Return: None
  238.  *
  239.  * Description: Fires when the 3rd page is loaded.  Sets focus on the relevant widget.
  240.  */
  241.  
  242. function page3onLoad()
  243. {
  244.   document.getElementById('p3inputscreenname').focus();
  245.   gCurPage = 3;
  246. }
  247.  
  248.  
  249.  
  250. //*************************//
  251. //     Panel Four JS       //
  252. //*************************//
  253.  
  254.  
  255. /*
  256.  * Function: page4onLoad
  257.  *
  258.  * Arguments: None
  259.  * 
  260.  * Return: None
  261.  *
  262.  * Description: Fires when the 4th page is loaded.  Sets focus on the relevant widget.
  263.  */
  264.  
  265. function page4onLoad()
  266. {
  267.   document.getElementById('p4inputscreenname').focus();
  268.   setFields('p4inputscreenname', parent.migrationScreenName);
  269.   setFields('p4inputpassword', parent.migrationPassword);
  270.   gCurPage = 4;
  271. }
  272.  
  273.  
  274. /*
  275.  * Function: setMigratedPanelFields
  276.  *
  277.  * Arguments: none
  278.  * 
  279.  * Return: none
  280.  *
  281.  * Description: Fill the menupopup with found AIM screennames.
  282.  */
  283.  
  284. function setFields(element,set)
  285. {
  286.   element = document.getElementById(element);
  287.  
  288.   if ( !element || element == null || element == undefined )
  289.     return;
  290.  
  291.   if (element.id == "p4inputscreenname")
  292.   {
  293.     ClearMenuList( element );
  294.     if (parent.migrationScreenName)
  295.       AppendStringToMenulist( element, parent.migrationScreenName );
  296.     for ( var i = 0; i < parent.migrationScreenNameVecSize.value; i++ )
  297.       AppendStringToMenulist( element, parent.migrationScreenNameVec[ i ] );
  298.   }
  299.   if (element.id == "p4inputpassword")
  300.     element.value = set;
  301. }    
  302.  
  303.  
  304. //*************************//
  305. //     Panel Five JS       //
  306. //*************************//
  307.  
  308.  
  309. /*
  310.  * Function: page5onLoad
  311.  *
  312.  * Arguments: none
  313.  * 
  314.  * Return: none
  315.  *
  316.  * Description: Fires when the 5th page is loaded.  Sets focus on the relevant widget, 
  317.  *              and sets the proper next page.
  318.  */
  319.  
  320. function page5onLoad()
  321. {
  322.   gCurPage = 5;
  323. }
  324.  
  325.  
  326.  
  327. //*************************//
  328. //      Panel Six JS       //
  329. //*************************//
  330.  
  331.  
  332. /*
  333.  * Function: page6onLoad
  334.  *
  335.  * Arguments: none
  336.  * 
  337.  * Return: none
  338.  *
  339.  * Description: Fires when the 6th page is loaded.  Sets focus on the relevant widget, 
  340.  *              and sets up the call to open the brower with the reg page open.
  341.  */
  342.  
  343. function page6onLoad()
  344. {
  345.   document.getElementById('p6inputscreenname').focus();
  346.   newRegBrowser(aimRegionString('register.site'))
  347.   gCurPage = 6;
  348. }
  349.  
  350.  
  351. //*************************//
  352. //      Panel Done JS       //
  353. //*************************//
  354.  
  355.  
  356. /*
  357.  * Function: pdoneonLoad
  358.  *
  359.  * Arguments: none
  360.  * 
  361.  * Return: none
  362.  *
  363.  * Description: Fires when the 6th page is loaded.  Sets focus on the relevant widget, 
  364.  *              and sets up the call to open the brower with the reg page open.
  365.  */
  366.  
  367. function pdoneonLoad()
  368. {
  369.     sname=gScreenName;
  370.     var snDom = document.getElementById("newScreenName")
  371.     snDom.setAttribute("value", sname);
  372.  
  373.   gCurPage = 99;
  374. }
  375.  
  376.  
  377.  
  378.  
  379. /*
  380.  * Function: newRegBrowser
  381.  *
  382.  * Arguments: theUrl
  383.  * 
  384.  * Return: none
  385.  *
  386.  * Description: Opens a browser window with the AIM new screen name registration page displayed.
  387.  */
  388.  
  389. function newRegBrowser(theUrl)
  390. {
  391.   aimCmdNewBrowser(theUrl);
  392. }
  393.  
  394.  
  395. //*************************//
  396. //    Finish/Cancel JS     //
  397. //*************************//
  398.  
  399.  
  400.  
  401. /*
  402.  * Function: wizardSetPrefs()
  403.  *
  404.  * Arguments: panelName,ns,pw
  405.  * 
  406.  * Return: None
  407.  *
  408.  * Description: called when the user has hit the finish button.  Sets the relevant prefs 
  409.  *              for their choice of screen name, and also registers the name somehow.
  410.  *              
  411.  */
  412. /*
  413. function wizardSetPrefs(sn,pw)
  414. {
  415.   aimPrefsManager().SetCharPref("aim.session.screenname", sn, null, true);
  416.   
  417.   if(pw != "")
  418.   {
  419.     aimSessionSavePassword(pw);
  420.     aimPrefsManager().SetBoolPref("aim.session.storepassword", true, null, false);
  421.   }
  422.  
  423.   aimPrefsManager().SetBoolPref("aim.session.autologin", false, null, false);
  424.  
  425.   wizardRegister(sn);
  426. }
  427. */
  428.  
  429. /*
  430.  * Function: wizardRegister()
  431.  *
  432.  * Arguments: screenName
  433.  * 
  434.  * Return: None
  435.  *
  436.  * Description: Registers the screenname?  (Please comment.)
  437.  */
  438. /*
  439. function wizardRegister(screenName)
  440. {
  441.   if(aimSessionObject())
  442.     aimSessionObject().RegisterScreenName(screenName);
  443. }
  444. */
  445.  
  446. /*
  447.  * Function: cancelWizard()
  448.  *
  449.  * Arguments: none
  450.  * 
  451.  * Return: None
  452.  *
  453.  * Description: Cancels the use of the wizard, and throws you out to the setup panel.
  454.  */
  455.  
  456. function cancelWizard()
  457. {
  458.   if (document.documentElement.currentPage.id == "ispPage12") {
  459.     gCreditPageCancelled =true;
  460.     document.documentElement.advance("ispPage13");
  461.     return false;
  462.   }
  463.   var aimBundle = document.getElementById('bundle_aim');  // Lets us access the AIM String Bundle.
  464.  
  465.   var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
  466.   promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
  467.   
  468.   var title   = aimBundle.getString("migwiz.cancel.title");
  469.   var message = aimBundle.getString("migwiz.cancel.text");
  470.   var result = {value:0};
  471.   
  472.   result = promptService.confirmEx(window, title, message, null, null, null, null, null, result);
  473.  
  474.   if (result == 1){
  475.        return false;
  476.     }else{
  477.        return true;
  478.     }
  479. }
  480.  
  481.  
  482. /*
  483.  * Function: finishWizard()
  484.  *
  485.  * Arguments: none
  486.  * 
  487.  * Return: None
  488.  *
  489.  * Description: Finishes the use of the wizard, and throws you out to the Sign On panel with whatever screen name you picked.
  490.  */
  491.  
  492. function finishWizard()
  493. {
  494.   var sname = "";
  495.   var pword = "";
  496.   var existingScreenName = aimPrefsManager().GetCharPref("aim.session.screenname", null, true);
  497.   var firstTimeUsingAim = aimPrefsManager().GetBoolPref("aim.session.firsttime", null, true);
  498.   var overrideExistingScreenName = false;
  499.  
  500.   switch(gCurPage)
  501.   {
  502.     case 2:
  503.       sname = existingScreenName
  504.       pword = "";
  505.     break;
  506.     case 3:
  507.       sname = document.getElementById("p3inputscreenname").value;
  508.       pword = document.getElementById("p3inputpassword").value;
  509.       overrideExistingScreenName = true;
  510.     break;
  511.     case 4:
  512.       sname = document.getElementById("p4inputscreenname").value;
  513.       pword = document.getElementById("p4inputpassword").value;
  514.       overrideExistingScreenName = true;
  515.     break;
  516.     case 6:
  517.       sname = document.getElementById("p6inputscreenname").value;
  518.       pword = document.getElementById("p6inputpassword").value;
  519.     break;
  520.     case 99:
  521.       // downstream activation
  522.       sname=gScreenName;
  523.       pword=gPassword;
  524.       overrideExistingScreenName = true;
  525.     break;
  526.   }
  527.  
  528.  
  529.   if( !(existingScreenName && existingScreenName !="") || ((overrideExistingScreenName == true)&&(aimRDFDataSource().GetTarget(aimRDFSession(), aimRDFSessionState(), true) == aimRDF().GetLiteral("Offline"))))
  530.   {
  531.      //we dont have a screen name set so set one --- or --- we want to override the existing screen name and we are offline.
  532.      
  533.      aimSessionRegister(sname);
  534.   
  535.      if(pword != "")
  536.      {
  537.        dump("\n in saving password option \n")
  538.        aimSessionSavePassword(pword);
  539.        aimPrefsManager().SetBoolPref("aim.session.storepassword", true, null, false);
  540.        
  541.        /*update sidebar sign on fields */
  542.        var migrationParentWindow = top.opener;//get the parent window of this wizard
  543.        var sideBarFrame = migrationParentWindow.getsidebarframe();//get the sidebar panel
  544.        var sideBarFramePassWordField = sideBarFrame.document.getElementById("fldPassword");
  545.        sideBarFramePassWordField.value = pword;
  546.        //enable the inputs like sign on and save password checkbox
  547.        sideBarFrame.EnableInputs();
  548.  
  549.      }
  550.  
  551.      aimPrefsManager().SetBoolPref("aim.session.finishedwizard",true, null, true);
  552.      aimPrefsManager().SetCharPref("aim.session.screenname", sname, null, true);
  553.      aimPrefsManager().SetCharPref("aim.session.latestaimscreenname",sname, null,true);
  554.      aimPrefsManager().SetBoolPref("aim.session.autologin", false, null, false);
  555.  
  556.      var checkbox = document.getElementById("p4migrateScreenNameCheck");
  557.   
  558.      if ( checkbox && checkbox.checked == false )
  559.      {
  560.        aimPrefsManager().SetCharPref("aim.session.migrateBuddyList",sname, null, true);
  561.      }
  562.   }
  563.   
  564.  
  565.   
  566.   
  567.   dump("finished finish wizard\n");
  568.   //closeWizard();
  569. }
  570.  
  571. function closeWizard()
  572. {
  573.   dump("calling close wizard\n");
  574.   top.window.close();
  575.   window.close();
  576.   top.close();
  577. }
  578.  
  579.  
  580. /**** set next page 
  581. *
  582. */
  583. function setNextPage(currentPageId, nextPageId) {
  584.     var currentPage = document.getElementById(currentPageId);
  585.     currentPage.next = nextPageId;
  586. }